package com.ssyt.hiring.talent.service;

import java.util.ArrayList;
import java.util.List;

import com.ssyt.hiring.common.util.DBUtil;
import com.ssyt.hiring.talent.entity.ResumeEntity;

public class ResumeService {

	/**
	 * 查询当前求职者的所有简历信息
	 * 
	 * @param talentId
	 * @return
	 */
	public List<ResumeEntity> listResumeByTalentId(int talentId) {
		return DBUtil.executeQuery(ResumeEntity.class,
				"SELECT * FROM resume WHERE talent_id=? ORDER BY id DESC",
				talentId);
	}

	/**
	 * 添加简历
	 * 
	 * @param resume
	 */
	public int add(ResumeEntity resume) {
		List<Object> paramList = new ArrayList<>();
		paramList.add(resume.getTalentId());
		paramList.add(resume.getIntention());
		paramList.add(resume.getWorkExperience());
		paramList.add(resume.getProjectExperience());
		return DBUtil.executeUpdate(
				"INSERT INTO resume VALUES(NULL, ?, ?, ?, ?)", paramList);
	}

	/**
	 * 删除指定的简历
	 * 
	 * @param resumeId
	 * @return
	 */
	public int delete(int resumeId) {
		return DBUtil.executeUpdate("DELETE FROM resume WHERE id=?", resumeId);
	}
}
